#include <iostream>
#include <string>
#include "../Headers/types.h"

#include "tui.filesharing.h"
#include "tui.utils.h"

void tuiFileSharing(TOB::Shell &shell, std::stringstream &stream) {
  std::string fileid;
  uint32 counter = 0;

  // Receive action 
  std::string action;
  stream >> action;

  // Upload 
  if(action == "upload") {
    while(true) {
      fileid = "";
      stream >> fileid;
      if(fileid.size() == 0) break;
      ++counter;
    }
    shell.write(counter).write(" files were uploaded.").writeLine();

  // Download
  } else if (action == "download") {
    while(true) {
      fileid = "";
      stream >> fileid;
      if(fileid.size() == 0) break;
      ++counter;
    };
    shell.write(counter).write(" files were downloaded.").writeLine();

  // Unknown action
  } else {
    shell.write("Using: {upload|download} [file1 [file2 ..]]").writeLine();

  }
}
